package user

import (
	"context"
	"github.com/jinzhu/copier"
	"github.com/zeromicro/go-zero/core/logx"
	"go.uber.org/zap"
	"navi-mumbai/app/api/business/internal/svc"
	"navi-mumbai/app/api/business/internal/types"
	"navi-mumbai/app/rpc/usercenter/pb"
)

type GetSmsVerifyCodeLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGetSmsVerifyCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSmsVerifyCodeLogic {
	return &GetSmsVerifyCodeLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GetSmsVerifyCodeLogic) GetSmsVerifyCode(req *types.GetSmsVerifyCodeReq) (resp *types.GetSmsVerifyCodeResp, err error) {
	l.Logger.Infof("GetSmsVerifyCode uid %d content %s ", req.AreaNo, req.PhoneNo)
	var in pb.GetSmsVerifyCodeReq
	in.AreaNo = req.AreaNo
	in.PhoneNo = req.PhoneNo
	var rsp *pb.GetSmsVerifyCodeResp
	rsp, err = l.svcCtx.UcUserRpc.GetSmsVerifyCode(l.ctx, &in)
	if err != nil {
		l.Logger.Errorf("err == ", zap.Error(err))
		return
	}
	copier.Copy(resp, rsp)
	return
}
